package net.pugsplace.gpremacy.rules;

import net.pugsplace.gpremacy.state.GameState;

/**
 * Describes one type of battle
 * 
 * @author pug@pugsplace.net
 */
public interface OrderOfBattle {
	/**
	 * Determine if this is a valid battle
	 * 
	 * @param attacker
	 *            The unit type of the attacker
	 * @param defender
	 *            The unit type of the defender
	 * @param phase
	 *            The current phase of play
	 * @return True if a call to doBattle() with these types would be valid.
	 */
	public boolean applicableTo(UnitType attacker, UnitType defender, Phase phase);

	/**
	 * Perform a battle between the attackers and defenders and update the game
	 * state with the results; this method will be called with arguments such
	 * that each defender in defenders are of the same UnitType and that each
	 * attacker in attackers are of the same UnitType. Multiple calls may be
	 * made to this method if one set of attackers attacks two different types
	 * of defenders in one phase.
	 * 
	 * @param defenders
	 *            An array of units OF THE SAME UNITTYPE which are defending
	 * @param attackers
	 *            An array of units OF THE SAME UNITTYPE which are attacking
	 * @param state
	 *            The current game state
	 */
	public void doBattle(Unit[] defenders, Unit[] attackers, GameState state);
}
